<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<style type="text/css">
			div{
				width: 200px;
				height: 80px;
				background: firebrick;
				position: absolute;
			}
		</style>
	</head>

	<body>
		
		<div class="test"></div>
		<div class="test2">阿富阿富你真帅</div>
		<script src="js/jquery-2.1.0.js" type="text/javascript" charset="utf-8"></script>
		<script type="text/javascript">
			
			var drag = function(obj) {
				obj.on("touchstart", start);

				function start(e) {
					$(document).on("touchmove", move);
					$(document).on("touchend", stop);
					lastX = e.originalEvent.touches[0].clientX;
					lastY = e.originalEvent.touches[0].clientY;
					console.log(lastX)
					function move(e) {
						curX = e.originalEvent.touches[0].clientX;
						curY = e.originalEvent.touches[0].clientY;
//						console.log(curX)
						moveX = curX - lastX;
						moveY = curY - lastY;
						obj.css({
							"left": function(i, v) {
								return parseFloat(v) + moveX
							},
							"top": function(i, v) {
								return parseFloat(v) + moveY
							}
						});
						lastX = curX;
						lastY = curY
					}

					function stop() {
						$(document).off("touchmove", move);
						$(document).off("mouseup", stop);
					}
				}
			}
			drag($(".test"));
			drag($(".test2"));
		</script>
	</body>

</html>